// 设计一个音乐播放器类MusicPlayer，
// 包括属性有音乐列表、当前播放的音乐、播放模式等，
// 并能够实现添加音乐、删除音乐、播放音乐等方法。
// （随意设计）

import scala.collection.mutable.ArrayBuffer

// 音乐播放器类
class MusicPlayer {
  var musicList: ArrayBuffer[(String, String)] = ArrayBuffer()
  var currentMusic: Option[(String, String)] = None
  var playMode: String = "Sequential"

  // 添加音乐
  def addMusic(title: String, artist: String): Unit = {
    musicList += ((title, artist))
    println(s"Added music: $title - $artist")
  }

  // 删除音乐
  def removeMusic(title: String, artist: String): Unit = {
    musicList = musicList.filterNot(_ == (title, artist))
    println(s"Removed music: $title - $artist")
  }

  // 播放音乐
  def playMusic(title: String, artist: String): Unit = {
    currentMusic = Some((title, artist))
    println(s"Now playing: $title - $artist")
  }

  // 切换播放模式
  def changePlayMode(mode: String): Unit = {
    playMode = mode
    println(s"Changed play mode to: $mode")
  }

  // 显示音乐列表
  def showMusicList(): Unit = {
    println("Music List:")
    musicList.foreach { case (title, artist) =>
      println(s"$title - $artist")
    }
  }
}







